package com.guiji.quartz.task;

import com.guiji.quartz.domain.WangyiNews;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import us.codecraft.webmagic.Site;
import us.codecraft.webmagic.Spider;
import us.codecraft.webmagic.model.ConsolePageModelPipeline;
import us.codecraft.webmagic.model.OOSpider;

/**
 * @program: cms-vue-plus
 * @description:
 * @author: gaoX
 * @create: 2021-08-09 14:17
 **/
@Component("wangyiTask")
public class WangyiTask {
	private static final Logger log = LoggerFactory.getLogger(WangyiTask.class);
	public void wangyiSportAndEnt() throws InterruptedException {
		log.info("wangyiTask-start");
		Long startTime = System.currentTimeMillis();
		Spider spider = OOSpider.create(Site.me().setSleepTime(1000), new ConsolePageModelPipeline(), WangyiNews.class)
			.addUrl("https://sports.163.com/")
			.addUrl("https://tech.163.com/")
			.addUrl("https://money.163.com/")
			.addUrl("https://war.163.com/")
			.addUrl("https://ent.163.com/")
			.thread(20);
		spider.run();
		log.info("wangyiTask-end-:{}",System.currentTimeMillis()-startTime);
	}
}
